package com.pat.java.base.event;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Panel;
import java.awt.Scrollbar;
import java.awt.TextArea;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

public class UseAdjustmentEvent extends Applet implements AdjustmentListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Scrollbar s;
	TextArea txtValue;
	Panel p;

	public void init() {
		s = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 10, 36);

		s.addAdjustmentListener(this);
		txtValue = new TextArea(5, 25);

		p = new Panel(new BorderLayout());
		p.add(s, BorderLayout.NORTH);

		p.add(txtValue, BorderLayout.SOUTH);
		add(p);
	}

	public void start() {
	}

	public void adjustmentValueChanged(AdjustmentEvent e) {
		int value;
		Font oldF;
		if (e.getAdjustable() == s) {

			value = e.getValue();

			txtValue.setText(new Integer(value).toString());

			oldF = txtValue.getFont();
			txtValue.setFont(new Font(oldF.getName(), oldF.getStyle(), value));
		}
	}
}
